package leetcode算法面试题.排序与检索;

import java.util.Arrays;

public class 最大数 {
    class Solution{
        public String largestNumber(int[] nums){
            int len = nums.length;
            String[] str = new String[len];
            for (int i = 0; i < len; i++) {
                str[i] = ""+nums[i];
            }
            Arrays.sort(str,(a,b)->{
                String sa = a+b,sb=b+a;
                return sb.compareTo(sa);
            });
            StringBuilder sb = new StringBuilder();
            for (String s :
                    str) {
                sb.append(s);
            }
            int leng = sb.length();
            int k = 0;
            while (k<len-1&&sb.charAt(k)=='0') k++;
            return sb.substring(k);
        }
    }
}
